package Vista;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;

import net.miginfocom.swing.MigLayout;
import java.awt.Font;
import javax.swing.JPasswordField;

import Controlador.Controlador;

public class Panel_Login extends JPanel { 

	// Paneles
		private JPanel panelPrin;
		private JPanel panelCentral;
		private JPanel panelCombo;
		private JPanel panelDni;
		private JPanel panelPass;
		private JPanel panelInf;
		
		// ComboBox
		private JComboBox comboTipoUsu;
		
		// Etiquetas
		private JLabel labelDni;
		private JLabel labelPass;
		
		// Text field
		private JTextField campoDni;
		private JPasswordField campoPass;
		
		// Botones
		private JButton botonAcceder;
		private JButton botonSalir;

	/**
	 * Create the panel.
	 * @param control 
	 */
	public Panel_Login(Controlador control) {

		// Instanciar paneles
				panelPrin = new JPanel();
				panelPrin.setPreferredSize(new Dimension(270, 200));
				panelPrin.setMaximumSize(new Dimension(270, 139));
				panelPrin.setBorder(new LineBorder(new Color(100, 149, 237), 2));
				panelCentral = new JPanel();
				panelCombo = new JPanel();
				panelDni = new JPanel();
				panelPass = new JPanel();
				panelInf = new JPanel();
				
				// Instanciar combo
				comboTipoUsu = new JComboBox();
				comboTipoUsu.setFont(new Font("Dialog", Font.BOLD, 18));
				comboTipoUsu.setPreferredSize(new Dimension(32, 30));
				// Instanciar etiquetas
				labelDni = new JLabel("DNI:");
				labelDni.setPreferredSize(new Dimension(29, 30));
				labelDni.setFont(new Font("Dialog", Font.PLAIN, 18));
				//labelDni.setPreferredSize(new Dimension(29, 30));
				labelPass = new JLabel("Contraseña:");
				labelPass.setPreferredSize(new Dimension(88, 30));
				labelPass.setFont(new Font("Dialog", Font.PLAIN, 18));
				// Instanciar campos de texto
				campoDni = new JTextField();
				campoDni.setFont(new Font("Dialog", Font.PLAIN, 16));
				campoPass = new JPasswordField();
				campoPass.setFont(new Font("Dialog", Font.PLAIN, 16));
				// Instanciar botones
				botonAcceder = new JButton("Acceder");
				botonAcceder.setFont(new Font("Dialog", Font.BOLD, 18));
				botonSalir = new JButton("Salir");
				botonSalir.setFont(new Font("Dialog", Font.PLAIN, 18));
			
				
				// Definimos el color de fondo para los paneles
				//panelPrin.setBackground(new Color(102, 153, 204));
				panelCentral.setBackground(new Color(176, 196, 222));
				panelCombo.setBackground(new Color(173, 216, 230));
				panelDni.setBackground(new Color(173, 216, 230));
				panelPass.setBackground(new Color(173, 216, 230));
				panelInf.setBackground(new Color(176, 196, 222));
				
				// Anadimos los paneles
				panelPrin.setLayout(new BorderLayout(0, 0));
				panelPrin.add(panelCentral, BorderLayout.CENTER);
				panelPrin.add(panelInf, BorderLayout.SOUTH);
				panelCentral.setLayout(new MigLayout("", "[grow]", "[][10.00][][10.00][]"));
				
				panelCentral.add(comboTipoUsu, "cell 0 0, grow");
				comboTipoUsu.addItem("Cliente");
				comboTipoUsu.addItem("Administrador");
				
				panelCentral.add(labelDni, "cell 0 2");
				panelCentral.add(campoDni, "cell 0 2,grow");
					
				panelCentral.add(labelPass, "cell 0 4");
				panelCentral.add(campoPass, "cell 0 4,grow");
				
				panelInf.setLayout(new BorderLayout(0, 0));
				panelInf.add(botonSalir, BorderLayout.WEST);
				panelInf.add(botonAcceder, BorderLayout.EAST);
				
				this.add(panelPrin);
	}

	/*
	 * Accesores
	 */
	/**
	 * @return the comboTipoUsu
	 */
	public JComboBox getComboTipoUsu() {
		return comboTipoUsu;
	}

	/**
	 * @param comboTipoUsu the comboTipoUsu to set
	 */
	public void setComboTipoUsu(JComboBox comboTipoUsu) {
		this.comboTipoUsu = comboTipoUsu;
	}

	/**
	 * @return the campoDni
	 */
	public JTextField getCampoDni() {
		return campoDni;
	}

	/**
	 * @param campoDni the campoDni to set
	 */
	public void setCampoDni(JTextField campoDni) {
		this.campoDni = campoDni;
	}

	/**
	 * @return the campoPass
	 */
	public JPasswordField getCampoPass() {
		return campoPass;
	}

	/**
	 * @param campoPass the campoPass to set
	 */
	public void setCampoPass(JPasswordField campoPass) {
		this.campoPass = campoPass;
	}

	/**
	 * @return the botonAcceder
	 */
	public JButton getBotonAcceder() {
		return botonAcceder;
	}

	/**
	 * @param botonAcceder the botonAcceder to set
	 */
	public void setBotonAcceder(JButton botonAcceder) {
		this.botonAcceder = botonAcceder;
	}

	/**
	 * @return the botonSalir
	 */
	public JButton getBotonSalir() {
		return botonSalir;
	}

	/**
	 * @param botonSalir the botonSalir to set
	 */
	public void setBotonSalir(JButton botonSalir) {
		this.botonSalir = botonSalir;
	}
	
	
}
